﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.WindowsAzure.StorageClient;

namespace AzureGames.Data.Implementation.ServiceEntities
{
    public class GameDefinitionEntity : BaseTableEntity
    {        
        public string Name { get; set; }
        public double Version { get; set; }
        public string ShortDescription { get; set; }
        public string Description { get; set; }
        public Guid GameImage { get; set; }
        public int ID { get; set; }
        public string HTML { get; set; }
        public List<Guid> CSSFiles { get; set; }
        public List<Guid> JavascriptFiles { get; set; }
        public List<Guid> Media { get; set; }
        public List<string> StartingProperties { get; set; }
        public int RequiredNumberOfPlayers { get; set; }
        public string Instructions { get; set; }

        public static implicit operator Model.GameDefinition(GameDefinitionEntity from)
        {
           return AutoMapper.Mapper.Map<GameDefinitionEntity, Model.GameDefinition>(from);

        }

        public static implicit operator GameDefinitionEntity(Model.GameDefinition from)
        {
            return AutoMapper.Mapper.Map<Model.GameDefinition, GameDefinitionEntity>(from);
        }

        // TODO: the automapper was failing; investigate why
        public static Model.GameDefinition ToModel(GameDefinitionEntity from)
        {
            return new Model.GameDefinition

            {
                ID = from.ID,
                CreatedDate = from.CreatedDate,
                CSSFiles = from.CSSFiles,
                Description = from.Description,
                GameImage = from.GameImage,
                HTML = from.HTML,
                Instructions = from.Instructions,
                JavascriptFiles = from.JavascriptFiles,
                LastUpdatedDate = from.LastUpdatedDate,
                Media = from.Media,
                Name = from.Name,
                RequiredNumberOfPlayers = from.RequiredNumberOfPlayers,
                ShortDescription = from.ShortDescription,
                StartingProperties = from.StartingProperties,
                Version = from.Version
            };

        }
    }
}
